<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>reviewer</title>
        <link href="../../script/seminar.css" rel="stylesheet"/>
        <script type="text/javascript">
            function fnLogOut() {
                document.reviewerForm.method = 'POST';
                document.reviewerForm.action = '../../logic/logout.php';
                document.reviewerForm.submit();
            }
            function fnSlctPembicara() {
                var vIdxPembicara = document.getElementById("slctPembicara").selectedIndex;
                var vIdPembicara = document.getElementById("slctPembicara")[vIdxPembicara].value;
                document.reviewerForm.hidIdPembicara.value = vIdPembicara;
                document.reviewerForm.method = 'POST';
                document.reviewerForm.action = '../../logic/getDetilPembicaraReviewer.php';
                document.reviewerForm.submit();
            }
            
            function fnDownloadFile(vPaperId) {
                document.reviewerForm.hidPaperId.value = vPaperId;
                document.reviewerForm.method = 'POST';
                document.reviewerForm.action = '../../logic/FileDownload.php';
                document.reviewerForm.submit();
            }
            
            function fnOldUser() {
                document.reviewerForm.method = 'POST';
                document.reviewerForm.action = '../user/oldUser.php';
                document.reviewerForm.submit();
            }
            
            function fnSaveKomen(num) {
                document.reviewerForm.hidNum.value = num;
                var vScore = document.getElementById('txtScore_' + num).value;
                if (vScore == '') {
                    alert('Anda belum memberikan nilai!');
                } else {
                    document.reviewerForm.method = 'POST';
                    document.reviewerForm.action = '../../logic/saveKomen.php';
                    document.reviewerForm.submit();
                }
            }
            
            function fnSendSms(vNoHp,vNum) {
                var vWinH = document.body.offsetHeight;
                var vWinW = document.body.offsetWidth;
                var vPopupH = 300;
                var vPopupW = 630;
                var vPosTop = (vWinH-vPopupH)/2;
                var vPosLeft = (vWinW-vPopupW)/2;
                
                // revisi
                var vKomen = document.getElementById('txtKomen_' + vNum).value;
                var vURL = "smsFormReviewer.php?init=1&noHp=" + String(vNoHp) + "&vKomentar=" + vKomen;
                
                var vName = "SMS Form";
                var vSpecs = "width="+vPopupW+", height="+vPopupH+", top="+vPosTop+", left="+vPosLeft+", titlebar=no, menubar=no, status=no, resizable=no";
                window.open(vURL, vName, vSpecs);
            }
            
            function fnRefresh() {
                location.reload();
            }
        </script>
    </head>
    <body>
        <?php
        include("../../utility/connection.php");
        include("../../utility/general.php");
        include("../../model/mPaper.php");
        
        include("../../model/mUser.php");
        include("../../model/mSeminar.php");
        include("../../model/mUserSeminar.php");
        
        include("../../model/mSMS.php");
        session_start();
        if (isset($_SESSION['arrResult'])) {
            $arrResult = $_SESSION['arrResult'];
        ?>
        <form name="reviewerForm" id="reviewerForm">
        <input type="hidden" name="hidIdPembicara" id="hidIdPembicara">
        <input type="hidden" name="hidHpPembicara" id="hidHpPembicara">
        <input type="hidden" name="hidNum" id="hidNum">
        <input type="hidden" name="hidPaperId" id="hidPaperId">
        <input type="hidden" name="hidIdReviewer" id="hidIdReviewer" value="<?php echo $arrResult[0] ?>">
        <table border="0" width="100%" height="100%">
            <tr valign="middle">
                <td align="center">
                    
                    <table width="90%" border="0" cellpadding="2" cellspacing="0">
                        <tr class="tbl-body">
                            <td width="20px">
                                <table width="100%" border="0" cellpadding="5" cellspacing="0">
                                    <tr class="tbl-header">
                                        <td>DAFTAR&nbsp;PEMBICARA</td>
                                    </tr>
                                    <tr>
                                        <td>
                                            <select name="slctPembicara" id="slctPembicara" onchange="fnSlctPembicara()" style="width: 200px" size="18">
                                                <?php
                                                $speakerId = '';
                                                if (isset($_SESSION['speakerId'])) {
                                                    $speakerId = $_SESSION['speakerId'];
                                                }
                                                
                                                $topikId = '';
                                                if (isset($_POST['hidIdTopik'])) {
                                                    $topikId = trim(mysql_real_escape_string($_POST['hidIdTopik']));
                                                } else {
                                                    $topikId = $_SESSION['topikId'];
                                                } 
                                                $_SESSION['topikId'] = $topikId;
                                                
                                                $resultAllSpeaker = fnGetAllSpeaker($topikId);
                                                if ($resultAllSpeaker) {
                                                    while($rowSpeaker = mysql_fetch_row($resultAllSpeaker)){
                                                ?>
                                                <option value="<?php echo $rowSpeaker[0] ?>"><?php echo $rowSpeaker[1] ?>
                                                <?php
                                                    }
                                                }
                                                ?>
                                            </select>
                                        </td>
                                    </tr>
                                </table>
                            </td>
                            <td>
                                <table width="100%" height="100%" border="0" cellpadding="5" cellspacing="0">
                                    <tr class="tbl-header">
                                        <td colspan="3">DETIL&nbsp;PEMBICARA</td>
                                    </tr>
                                    <?php
                                    if (isset($_SESSION['userResult'])) {
                                        $userSeminar = $_SESSION['userResult'];
                                        $UserId = $userSeminar[0];
                                        $NoTelp = strval($userSeminar[7]);
                                    ?>
                                    <tr class="tbl-body">
                                        <td>Nama</td>
                                        <td>&nbsp;:&nbsp;</td>
                                        <td width="80%"><?php echo $userSeminar[1] ?></td>
                                    </tr>
                                    <tr class="tbl-body">
                                        <td>Alamat</td>
                                        <td>&nbsp;:&nbsp;</td>
                                        <td width="80%"><?php echo $userSeminar[2] ?></td>
                                    </tr>
                                    <tr class="tbl-body">
                                        <td>Kota</td>
                                        <td>&nbsp;:&nbsp;</td>
                                        <td width="80%"><?php echo $userSeminar[3] ?></td>
                                    </tr>
                                    <tr class="tbl-body">
                                        <td>Propinsi</td>
                                        <td>&nbsp;:&nbsp;</td>
                                        <td width="80%"><?php echo $userSeminar[4] ?></td>
                                    </tr>
                                    <tr class="tbl-body">
                                        <td>Negara</td>
                                        <td>&nbsp;:&nbsp;</td>
                                        <td width="80%"><?php echo $userSeminar[5] ?></td>
                                    </tr>
                                    <tr class="tbl-body">
                                        <td>Kode&nbsp;Pos</td>
                                        <td>&nbsp;:&nbsp;</td>
                                        <td width="80%"><?php echo $userSeminar[6] ?></td>
                                    </tr>
                                    <tr class="tbl-body">
                                        <td>Telepon</td>
                                        <td>&nbsp;:&nbsp;</td>
                                        <td width="80%"><?php echo $NoTelp ?></td>
                                    </tr>
                                    <tr class="tbl-body">
                                        <td>Email</td>
                                        <td>&nbsp;:&nbsp;</td>
                                        <td width="80%"><?php echo $userSeminar[8] ?></td>
                                    </tr>
                                    <tr class="tbl-body">
                                        <td>User&nbsp;Name</td>
                                        <td>&nbsp;:&nbsp;</td>
                                        <td width="80%"><?php echo $userSeminar[9] ?></td>
                                    </tr>
                                    <tr class="tbl-body">
                                        <td>Password</td>
                                        <td>&nbsp;:&nbsp;</td>
                                        <td width="80%"><?php echo $userSeminar[10] ?></td>
                                    </tr>
                                </table>
                            </td>
                        </tr>
                        <tr class="tbl-body">
                            <td colspan="2">
                                <table width=100%" height="100%" border="1" cellpadding="5" cellspacing="0">
                                    <tr class="tbl-header">
                                        <td>No</td>
                                        <td>Tema</td>
                                        <td>Tgl&nbsp;Upload</td>
                                        <td>Nama&nbsp;File</td>
                                        <td>Action</td>
                                    </tr>
                                    <?php
                                    // revisi
                                    $topikId = '';
                                    if (isset($_SESSION['topikId'])) {
                                        $topikId = $_SESSION['topikId'];
                                    }
                                    
                                    // revisi
                                    $resultFileInfo = fnGetFileInfoByUserAndTopic($speakerId,$topikId);
                                    //$resultFileInfo = fnGetFileInfo($UserId);
                                    
                                    if ($resultFileInfo) {
                                        $TotalRow = mysql_num_rows($resultFileInfo);
                                        $num = 1;
                                        $seminarId0 = '';
                                        while($rowFileInfo = mysql_fetch_row($resultFileInfo)){
                                            $tglOrig = $rowFileInfo[9];
                                            $digitTgl = substr($tglOrig,-2,2);
                                            $digitBulan = fnConvertMonth(substr($tglOrig,-5,2));
                                            $digitTahun = substr($tglOrig,0,4);
                                            $paperId = $rowFileInfo[4];
                                            $userId = $rowFileInfo[1];
                                            $seminarId = $rowFileInfo[0];
                                            
                                            $resultScore = fnGetPaperScore($paperId, $userId, $seminarId, $arrResult[0]);
                                            $cekRow = mysql_num_rows($resultScore);
                                            $resScore = '';
                                            $resKomenReviewer = '';
                                            if ($cekRow > 0) {
                                                $arrResult1 = mysql_fetch_array($resultScore);
                                                $resScore = $arrResult1[13];
                                                $resKomenReviewer = $arrResult1[14];
                                            }
                                    ?>
                                    <tr>
                                        <td><?php echo $num ?></td>
                                        <td><?php echo $rowFileInfo[3] ?></td>
                                        <td align="center"><?php echo $digitTgl ?>&nbsp;<?php echo $digitBulan ?>&nbsp;<?php echo $digitTahun ?></td>
                                        <td width="640"><?php echo $rowFileInfo[7] ?></td>
                                        <td align="center">
                                            <button type="button" style="width: 100px;" name="btSmsSpeaker" id="btSmsSpeaker" onclick="fnSendSms('<?php echo $NoTelp ?>','<?php echo $num ?>')">Kirim Pesan</button>
                                            <br>
                                            <button type="button" style="width: 100px;" name="btDownload" id="btDownload" onclick="fnDownloadFile(<?php echo $rowFileInfo[4] ?>)">Download</button>
                                        </td>
                                    </tr>
                                    <?php 
                                    if ($seminarId0 == '') {
                                        $seminarId0 = $seminarId;
                                    }

                                    $readOnly = '';
                                    $style = '';
                                    if ($resScore != '') {
                                        $readOnly = "READONLY";
                                        $style = "style='display: none'";
                                    } else if (($seminarId0 == $seminarId) && ($num < $TotalRow)) {
                                        $readOnly = "style='display: none'";
                                        $style = "style='display: none'";
                                    }
                                    ?>
                                    <tr <?php echo $readOnly ?>>
                                        <td colspan="5" <?php echo $readOnly ?>>
                                            <label <?php echo $readOnly ?>>Komentar<br></label>
                                            <textarea <?php echo $readOnly ?> name="txtKomen_<?php echo $num ?>" id="txtKomen_<?php echo $num ?>" rows="5" cols="140"><?php echo $resKomenReviewer ?></textarea>
                                            <br>
                                            <label <?php echo $readOnly ?>>Nilai<br></label>
                                            <input <?php echo $readOnly ?> style="text-align: right" size="2" maxlength="3" type="text" name="txtScore_<?php echo $num ?>" id="txtScore_<?php echo $num ?>" value="<?php echo $resScore ?>">
                                            <input style="display: none" type="text" name="hidPaperId_<?php echo $num ?>" id="hidPaperId_<?php echo $num ?>" value="<?php echo $paperId ?>">
                                            <input style="display: none" type="text" name="hidUserId_<?php echo $num ?>" id="hidUserId_<?php echo $num ?>" value="<?php echo $userId ?>">
                                            <input style="display: none" type="text" name="hidSeminarId_<?php echo $num ?>" id="hidSeminarId_<?php echo $num ?>" value="<?php echo $seminarId ?>">
                                            <input style="display: none" type="text" name="hidRevId_<?php echo $num ?>" id="hidRevId_<?php echo $num ?>" value="<?php echo $arrResult[0] ?>">
                                            <button <?php echo $style ?> type="button" name="btSaveKomen" id="btSaveKomen" onclick="fnSaveKomen(<?php echo $num ?>)">Simpan</button>
                                        </td>
                                    </tr>
                                    <?php
                                        $num = $num + 1;
                                        }
                                    }
                                    ?>
                                </table>
                            </td>
                        </tr>
                        <?php 
                        }
                        ?>
                    </table>
                    
                </td>
            </tr>
            <tr valign="middle">
                <td align="center">
                    <button type="button" name="btOldUser" id="btOldUser" onclick="fnOldUser()">Kembali</button>
                    <button type="button" name="btLogOut" id="btLogOut" onclick="fnLogOut()">LogOut</button>
                </td>
            </tr>
        </table>
        </form>
        <?php
        }
        ?>
    </body>
</html>
